//
//  WDLoginAccountView.m
//  wd-serviceapp
//
//  Created by Bin Tang on 2024/8/21.
//

#import "WDLoginAccountView.h"

@interface WDLoginAccountView ()
@property (nonatomic, strong) UILabel *areaCodeLabel;

@property (nonatomic, strong) CALayer *codeLine;

@property (nonatomic, strong) UITextField *accountTextField;

@end

@implementation WDLoginAccountView

- (void)initWithSubView {
    self.backgroundColor = [UIColor whiteColor];
    self.layer.borderColor = [UIColor colorWithHexString:@"#DDDDDD"].CGColor;
    self.layer.borderWidth = 1;
    self.layer.cornerRadius = 5;
    self.layer.masksToBounds = YES;
    
    [self initWithAreaCodeLabel];
    
    [self initWithCodeLine];
    
    [self initWithAccountTextField];
}

- (void)initWithAreaCodeLabel {
    if (!_areaCodeLabel) {
        NSString *str = @"+86";
        CGRect frame = CGRectMake(0, (self.height - 20) * 0.5, 50, 20);
        _areaCodeLabel = [UILabel createWithLabel:self frame:frame font:[UIFont systemFontOfSize:15 weight:UIFontWeightMedium] propertiesBlock:^(UILabel * _Nonnull label) {
            label.textColor = [UIColor colorWithHexString:@"#000000"];
            label.text = str;
            label.textAlignment = NSTextAlignmentCenter;
        }];
    }
}

- (void)initWithCodeLine {
    if (!_codeLine) {
        CGRect frame = CGRectMake(self.areaCodeLabel.right, (self.height - 14) * 0.5, 1, 14);
        _codeLine = [CALayer drawLine:self frame:frame lineColor:[UIColor colorWithHexString:@"#707070"]];
    }
}

- (void)initWithAccountTextField {
    if (!_accountTextField) {
        CGRect frame = CGRectMake(self.codeLine.right + 8, (self.height - 32) * 0.5, self.width - self.codeLine.right - 8, 32);
        _accountTextField = [[UITextField alloc] initWithFrame:frame];
        _accountTextField.attributedPlaceholder = [EDSUtility attributeTitle:@"请输入手机号" titleColor:[UIColor colorWithHexString:@"#999999"] titleFont:[UIFont systemFontOfSize:15 weight:UIFontWeightRegular] value:@"" valueColor:[UIColor colorWithHexString:@"#999999"] valueFont:[UIFont systemFontOfSize:15 weight:UIFontWeightRegular]];
        _accountTextField.font = [UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
        _accountTextField.textColor = kBlackColor;
        _accountTextField.textAlignment = NSTextAlignmentLeft;
        _accountTextField.borderStyle = UITextBorderStyleNone;
        _accountTextField.returnKeyType = UIReturnKeyDone;
        _accountTextField.keyboardType = UIKeyboardTypePhonePad;
        _accountTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
        [self addSubview:_accountTextField];
    }
}

@end
